/*Copyright (C) 2013-2021 LZE*/
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define mod 1000000007
#define eps 1e-6
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1000010;
const int M=100010;
string pattern,text;
int prefix_table[N],len,tlen;
void make_prefix_table(){
    len=pattern.length();
    int now,x;
    now=0;x=1;
    prefix_table[0]=0;
    while(x<len){
        if(pattern[now]==pattern[x]){
            prefix_table[x]=now+1;
            x++;now++;
        }
        else{
            while(now>0 && pattern[now]!=pattern[x])
                now=prefix_table[now-1];
            if(pattern[now]!=pattern[x]){
                x++;
                now=0;
            }
        }
    }
}
void move(){
    for(int i=len+1;i>0;i--){
        prefix_table[i]=prefix_table[i-1];
    }
    prefix_table[0]=-1;
}
void KMP(){
    int i=0,j=0;
    tlen=text.length();
    while(i<tlen){
        if(j==-1){
            i++;j=0;
        }
        else if(text[i]==pattern[j]){
            i++;j++;
        }else j=prefix_table[j];
        if(j==len){
            printf("%d\n",i-j+1);
            j=prefix_table[j];
        }
    }
}
int main() {
    cin>>text>>pattern;
    make_prefix_table();
    move();
    KMP();
    for(int i=1;i<=len;i++){
        printf("%d ",prefix_table[i]);
    }
    printf("\n");
	return 0;
}
